package com.kevinxiaoge.ruoli.strategy_model;

public class Context {
    private Strategy strategy;

    public Double calRecharge(Double charge, Integer type) {
        // 利用一个工厂去生成对应的策略
        strategy = StrategyFactory.getInstance().creator(ReChargeTypeEnum.from(type));
        if (strategy == null) {
            throw new RuntimeException("策略生成错误");
        }
        return strategy.calRecharge(charge);
    }
}
